package registryx

import (
	"time"

	configx "config"

	"dubbo.apache.org/dubbo-go/v3"
	"dubbo.apache.org/dubbo-go/v3/metrics"
)

var WithMetrics = dubbo.WithMetrics(
	metrics.WithEnabled(),                   // default false
	metrics.WithPrometheus(),                // set prometheus metric, default prometheus
	metrics.WithPrometheusExporterEnabled(), // enable prometheus exporter default false
	//http://localhost:9099/prometheus
	metrics.WithPort(9099),            // prometheus http exporter listen at 9099,default 9090
	metrics.WithPath("/prometheus"),   // prometheus http exporter url path, default /metrics
	metrics.WithMetadataEnabled(),     // enable metadata center metrics, default true
	metrics.WithRegistryEnabled(),     // enable registry metrics, default true
	metrics.WithConfigCenterEnabled(), // enable config center metrics, default true

	metrics.WithPrometheusPushgatewayEnabled(), // enable prometheus pushgateway
	metrics.WithPrometheusGatewayUsername(configx.EtcdUsername),
	metrics.WithPrometheusGatewayPassword(configx.EtcdPassword),
	metrics.WithPrometheusGatewayUrl(configx.PrometheusURL), // host:port or ip:port,“http://” is added automatically,do not include the “/metrics/jobs/…” part
	metrics.WithPrometheusGatewayInterval(time.Second*10),
	metrics.WithPrometheusGatewayJob("push"), // set a metric job label, job=push to metric

	metrics.WithAggregationEnabled(), // enable rpc metrics aggregations，Most of the time there is no need to turn it on, default false
	metrics.WithAggregationTimeWindowSeconds(30),
	metrics.WithAggregationBucketNum(10), // agg bucket num
)

var WithMetricsClient = dubbo.WithMetrics(
	metrics.WithEnabled(),
	metrics.WithPrometheus(),                // set prometheus metric
	metrics.WithPrometheusExporterEnabled(), // enable prometheus exporter
	metrics.WithPort(9097),                  // prometheus http exporter listen at 9097
	metrics.WithPath("/prometheus"),         // prometheus http exporter url path
	metrics.WithMetadataEnabled(),           // enable metadata center metrics
	metrics.WithRegistryEnabled(),           // enable registry metrics
	metrics.WithConfigCenterEnabled(),       // enable config center metrics

	metrics.WithPrometheusPushgatewayEnabled(), // enable prometheus pushgateway
	metrics.WithPrometheusGatewayUsername(configx.EtcdUsername),
	metrics.WithPrometheusGatewayPassword(configx.EtcdPassword),
	metrics.WithPrometheusGatewayUrl(configx.PrometheusURL), // host:port or ip:port,“http://” is added automatically,do not include the “/metrics/jobs/…” part
	metrics.WithPrometheusGatewayInterval(time.Second*10),
	metrics.WithPrometheusGatewayJob("push"), // set a metric job label, job=push to metric

	metrics.WithAggregationEnabled(), // enable rpc metrics aggregations，Most of the time there is no need to turn it on
	metrics.WithAggregationTimeWindowSeconds(30),
	metrics.WithAggregationBucketNum(10), // agg bucket num
)
